package DAO;

import Interfaces.IDeleteUser_Dao;
import Models.DeleteUser;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;

public class DeleteUser_Dao implements IDeleteUser_Dao {


    @Override
    public  DeleteUser deleteUser(String username, String pass) throws IllegalArgumentException {

        Connection conn = null;
        PreparedStatement pst = null;
        try {
            conn = javaconnect.connectDB();
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(DeleteUser_Dao.class.getName()).log(Level.SEVERE, null, ex);
        }
        String query = "DELETE  FROM user WHERE username=? and password=?";
        try {
            pst = conn.prepareStatement(query);
            pst.setString(1, username);
            pst.setString(2, pass);
            pst.execute();
            pst.close();
            conn.close();
            //TODO Fix the success
        } catch (SQLException e) {
            throw new IllegalArgumentException("Error in DeleteUser_Dao ");
        }
        return null;
    }
}
